<?php

namespace common\models\datas;

use Yii;
use common\components\extenders\MenuManage;

/**
 * This is the model class for table "{{%position}}".
 *
 * @property integer $id
 * @property string $position_key
 * @property string $position_description
 * @property string $setting
 */
class Position extends \common\components\bases\BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%position}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['position_description', 'setting'], 'string'],
            [['position_description', 'position_key'], 'required'],
            [['position_key'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '位置ID',
            'position_key' => '位置Key',
            'position_description' => '位置描述',
            'setting' => '设置',
        ];
    }

    public function extraFields()
    {
        return [
            'operate' => function () {
                return (new MenuManage(MenuManage::RECORD_ITEM_TOOLBAR, $this->attributes))->create();
            },
        ];
    }
}
